<%@ page language="java" contentType="text/html; charset=UTF-8" %>

<script src="<c:url value='/resources/js/manage.js'/>"></script>
<c:import url="../../../template/layout.jsp" charEncoding="UTF-8">
  <c:param name="title" value="码表类列表"/>
  <c:param name="body">


    <div class="content-title">码表类列表
      <p>${message.msg}</p>
    </div>
    <div class="container"
         style="background-color:#DCEAF4; width:1300px; height:500px;border-radius: 0px 0px 0px 0px;">
      <c:if test="${message!=null}">
        <div class="alert alert-danger" role="alert">${message.msg}</div>
      </c:if>
      <div class="btn-group pull-right" style="margin-bottom:8px;">
        <button <%--onclick="addCodetype('<c:url value="${pageContext.request.contextPath}/system/codetype/getCodetypeName"/>')"--%>
                class="btn btn-primary btn-xs"
                data-toggle="modal" data-target="#addCodetype">添加
        </button>
      </div><%----%>
      <p></p>
      <div class="col-sm-5 col-sm-offset-1">
        <form id="searchForm" method="get" action="/system/codetype/list"
              name="user">
          <div class="input-group">
            <input id="pageNo" name="pageNo" type="hidden" value="${pager.pageNo}"/>
            <input id="pageSize" name="pageSize" type="hidden" value="${pager.pageSize}"/>


          </div>
        </form>
      </div>
      <div class="main-content">

        <table class="table">
          <thead>
          <tr>
            <th>码表类名</th>
            <th>码表描述</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <c:forEach items="${pager.list}" var="codetype">
            <%--<s:iterator value="#request.roleList" var="role">--%>
            <tr class="success">
              <td>${codetype.viewName}</td>
              <td>${codetype.codetypeDescription}</td>

              <td>
                <button onclick="editCodetype('<c:url value="/system/codetype/getCodetype?id=${codetype.id}"/>')"
                        class="btn btn-primary btn-xs"
                        data-toggle="modal" data-target="#editCodeType">编辑
                </button>
                &nbsp;&nbsp;
                <button class="btn btn-primary btn-xs"
                        href="javascript:void(0)" data-toggle="tooltip" title="删除"
                        onclick="if (confirm('确认要删除本记录吗？此操作将不可恢复！'))
                                location = '<c:url
                                value="/system/codetype/delete?id=${codetype.id}"/>';
                                return false;">删除
                </button>


              </td>
            </tr>
            <%--</s:iterator>--%>
          </c:forEach>
          <tr>
              <%-- <td colspan="7">
                   <jsp:include page="../inc/pager.jsp">
                       <jsp:param value="manage_userList.action" name="url"/>
                       <jsp:param value="${userPager.totalRecord }" name="items"/>
                       <jsp:param value="isRead" name="params"/>
                   </jsp:include>
               </td>--%>
          </tr>
          </tbody>
        </table>
      </div>
      <div class="row">
        <div class="col-sm-12">
            ${pager}
        </div>
      </div>
    </div>
    <script type="text/javascript">


      function editCodetype(path) {
        $.ajax({
          url: path,
          type: 'get',
          async: true,
          dataType: 'json',
          success: function (codetype) {
            $('#edit_id').val(codetype.id);
            $('#edit_codetypeName').val(codetype.viewName);
            $('#edit_codetypeDescription').val(codetype.codetypeDescription);
          }
        });
      }
      function addCodetype(path) {
        $.ajax({
          url: path,
          type: 'get',
          async: true,
          dataType: 'json',
          success: function (codetype) {
            $.each(codetype, function (idx, obj) {
              var inp = '<input class="edit_check" type="checkbox" name="codetypeName" value="' + obj.codetypeName + '"/>' + '&nbsp;&nbsp;' + obj.viewName;
              $("#add_codetype").append(inp);
            });
            var inp2 = '<input  type="text" name="codetypeNameTemp" />';
            $("#add_codetype").append(inp2);
          }
        });
      }
    </script>
    <%--编辑修改模态框--%>
    <div class="modal fade" id="editCodeType" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              <span aria-hidden="true">&times;</span>
              <span class="sr-only">Close</span>
            </button>
            <h3 class="modal-title">编辑</h3>
          </div>
          <div class="modal-body">
            <form name="codeType" action="/system/codetype/update" method="POST">
              <div align="left" style="width: 300px; margin-right: auto; margin-left: auto;">
              <div class="form-group">
                <label class="control-label" for="edit_codetypeName">码表类名</label>
                <input type="text" class="form-control" id="edit_codetypeName" name="codetypeName"
                       required>
              </div>
              <div class="form-group">
                <label for="edit_codetypeDescription">码表描述</label>
                <input class="form-control" id="edit_codetypeDescription" name="codetypeDescription" required/>
              </div>
              <div class="form-group">
                <input class="form-control" type="hidden" name="id" id="edit_id"/>
              </div>
              <button class="btn btn-primary btn-lg btn-block" type="submit">
                确定
              </button>
                </div>
            </form>
            </div>
          </div>
        </div>
      </div>
    </div>
    <%--添加码表类记录--%>
    <div class="modal fade" id="addCodetype" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              <span aria-hidden="true">&times;</span>
              <span class="sr-only">Close</span>
            </button>
            <h3 class="modal-title">添加</h3>
          </div>
          <div class="modal-body">
            <form name="codeType" action="/system/codetype/edit" method="POST">
              <%--<div class="form-group">
                <label class="control-label">码表类名</label>

                <input type="select" class="form-control"  name="codetypeName"
                       required>
              </div>--%>
                <div id="add_codetype" class="form-group">
                  <label>码表类名</label>
                  <input type="text" class="form-control"  name="codetypeName"
                         required>
                </div>
              <div class="form-group">
                <label>码表描述</label>
                <input class="form-control" name="codetypeDescription" required/>
              </div>
              <button class="btn btn-primary btn-lg btn-block" type="submit">
                添加
              </button>
            </form>
          </div>
        </div>
      </div>
    </div>
  </c:param>
</c:import>
